// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill';
import Vue from 'vue';
import App from './App';
import router from './router';
import store from './store';
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.less'
import 'static/css/normalize.css';
import 'static/css/vars.scss';
import 'static/css/base.scss';
import 'static/css/page.scss';
import 'static/font/iconfont.css';
import 'moment/locale/zh-cn';
import moment from 'moment';
import plugins from './plugins';
// import global from './common/global.js';
moment.locale('zh-cn');
Vue.config.productionTip = false
Vue.use(Antd);
Vue.use(plugins);

Vue.prototype.global = global;
Vue.prototype.$moment = moment;

router.onError((error) => {
  const pattern = /Loading chunk (\d)+ failed/g;
  const isChunkLoadFailed = error.message.match(pattern);
  if (isChunkLoadFailed) {
    router.replace(router.history.pending.fullPath);
  } else {
    console.log(error)
  }
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App),
  beforeCreate() {
    Vue.prototype.$bus = this;
    Vue.prototype.dispatch = store.dispatch;
    Vue.prototype.state = store.state;
  }
});
